var events = require("events");
 var Emitter = events.EventEmitter;
 function Dog(name,energy){
     Emitter.call(this);
     this.name = name;
     this.energy=energy;
 }
 Dog.prototype = Emitter.prototype;
 Dog.prototype.bark = function(){
     if(this.energy>0){
        console.log(this.name +" barked! energy:"+ this.energy);
        this.energy-=1;
     }
     else{
         process.exit();
     }
     
 }
 module.exports = Dog;